// Copyright © 2023 ycq_work@163.com. All rights reserved.

/**
 * @Author: ycq_work@163.com
 * @DATE: 2023/10/8
 * @Description: 
*/
#ifndef MUSICPLAYBACKSTATUSBAR_H
#define MUSICPLAYBACKSTATUSBAR_H

#include <QtWidgets>

class MusicPlaybackStatusBar :public QWidget
{
    Q_OBJECT

public:
    explicit MusicPlaybackStatusBar(QWidget *parent = nullptr);

    // 类中用的参数
private:
    // 部分控件
    QLabel* progressBarTime = new QLabel;                   // 进度时间显示
    QLabel *songName = new QLabel;                          // 歌名标签
    QProgressBar *progressBar = new QProgressBar;           // 进度条


    bool _isPlaying = false;
    QString _songNameText = "yt音乐,听你想听";
    QString _nowTime = "00:00";
    QString _allTime = "00:00";
    int _progressBarInt {0};
public:
    void set_isPlaying(bool isPlaying);
    void set_allTime(const QString &allTime);
    void set_nowTime(const QString &nowTime);
    void set_songNameText(const QString &songNameText);
    void set_progressBarInt();



private:
    // 绘制界面
    void init();

    // 获取音乐封面
    static QPixmap getPixmapFromImageFile(const QString& filePath);
    // 设置进度条
    static QString setProgressQss(QProgressBar *bar, int barHeight, int barRadius, int fontSize,
                                   const QString &normalColor, const QString &chunkColor);

    // 设置当前的播放进度
    void setProgressBarInt(int progressBarInt);

    // 在槽函数中实现图标切换和发送布尔值给Player类
    void onPlayerBtnClicked(QPushButton* button);

    // 设置pushbutton的icon
    static void setPushButtonIcon(QPushButton* button, QSize buttonSize, QSize iconSize, const QString& url);
    static void setPushButtonIcon(QPushButton* button, const QString& url);


signals:
    void sendIsPlaying(bool isPlaying);
};


#endif //MUSICPLAYBACKSTATUSBAR_H
